home *** CD-ROM | disk | FTP | other *** search
/ Gekikoh Dennoh Club 2 / Gekikoh Dennoh Club Vol. 2 (Japan).7z / Gekikoh Dennoh Club Vol. 2 (Japan) (Track 01).bin / games / mashou / plugin / monocol.c < prev    next >
Text File  |  1997-05-30  |  1KB  |  64 lines

  1. /*
  2.                                 
  3.             パレットモノカラー化
  4.         monocol.x blue red green
  5.         blue :青成分(0-31)
  6.         red  :赤成分(0-31)
  7.         green:緑成分(0-31)
  8.         return        0:no error
  9.                 1:command error
  10.     パレットを、一度に、指定色の32階調色にする。
  11.                                 
  12.                         by SJOM
  13.  
  14.  
  15. */
  16.  
  17. #include <sys/iocs.h>
  18. #include <stdlib.h>
  19.  
  20. /*
  21. #include <stdio.h>
  22. */
  23.  
  24.  
  25.  
  26.  
  27. static void
  28. pal_mono(int m_bl,int m_rd,int m_gr)
  29. {
  30.     int block,code,col=0,bl=0,red=0,gr=0,Y=0;
  31.     for (block=2;block<16;block++) {
  32.     _iocs_spalet(0,block,-1);        /* dummy */
  33.         for (code=0;code<16;code++) {
  34.             gr=_iocs_spalet(code+0x80000000,block,-1);
  35.             bl=(gr>>=1) & 31;
  36.             red=(gr>>=5) & 31;
  37.             gr>>=5;
  38.             Y=(3*red+6*gr+bl)/10;
  39.             bl=Y*m_bl/32;
  40.             red=Y*m_rd/32;
  41.             gr=Y*m_gr/32;
  42.             col=(gr<<11) | (red<<6) | (bl<<1) | 1;
  43.             _iocs_spalet(code+0x80000000,block,col);
  44.         };
  45.     };
  46. }
  47.  
  48.  
  49. int
  50. main(int argc,char **argv)
  51. {
  52.     int blue=0,red=0,green=0;
  53.     if (argc!=4)
  54.         exit(1);
  55.     argv++;
  56.     blue=atoi(*argv++) & 31;
  57.     red=atoi(*argv++) & 31;
  58.     green=atoi(*argv++) & 31;
  59.     pal_mono(blue,red,green);
  60.     exit(0);
  61. }
  62.  
  63.  
  64.